Imports System.Reflection
Imports System.IO

Public Class SQL
    Inherits AbstractFileParser

    Protected Overloads Overrides Function Parse(ByVal lines() As String, ByVal project As BBXProject) As TableList
        tables = New TableList
        Dim ps As SQLParserState = SQLParserState.SQLParseNoTable
        Dim tmpL As String
        For i As Integer = 0 To lines.Length - 1
            tmpL = lines(i).Trim()
            Dim t As Type
            Try
                t = Type.GetType("pixolut.BizBloxBuilderCore." & ps.ToString())
                Dim parser As SQLParser = CType(t.InvokeMember(Nothing, BindingFlags.DeclaredOnly Or BindingFlags.Public Or BindingFlags.NonPublic Or BindingFlags.Instance Or BindingFlags.CreateInstance, Nothing, Nothing, New [Object]() {}), SQLParser)
                parser.Parse(lines(i), tables, project)
                ps = CType(parser.GetParserState(), SQLParserState)
            Catch ex As Exception
                Dim msg As String = ex.ToString & ps.ToString
                Debug.Print(msg)
            End Try
        Next
        'Console.WriteLine(tables.ToString())
        Return tables
    End Function
End Class
